<?php

namespace app\common\model;

use think\Model;


class RecommendRebate extends Model
{

    

    

    // 表名
    protected $name = 'recommend_rebate';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
	
	
	/**
	 * 获取推荐人的奖励金额
	 * @param $rule
	 * @param $level
	 * @param $prefix
	 * @return int
	 */
	public function getPidAmount($rule, $level, $prefix = '') {
		$userModel = new \app\admin\model\User();
		switch ($level) {
			case $userModel::LEVEL_VIP:
				$amount = $rule[$prefix.'vip'];
				break;
			
			case $userModel::LEVEL_OWNER:
				$amount = $rule[$prefix.'agent_owner'];
				break;
			case $userModel::LEVEL_SHOP:
				$amount = $rule[$prefix.'agent_shop'];
				break;
			case $userModel::LEVEL_AGENT:
				$amount = $rule[$prefix.'agent_agent'];
				break;
			case $userModel::LEVEL_PARTNER:
				$amount = $rule[$prefix.'agent_partner'];
				break;
			case $userModel::LEVEL_FOUNDER:
				$amount = $rule[$prefix.'agent_founder'];
				break;
			default:
				$amount = 0;
		}
		
		return $amount;
	}
	



}
